#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @Time   : 2021/6/27 15:32
# @Author : cjw
from time import sleep

from web_wework.page.base_page import BasePage
from web_wework.setting import ELEMENT_YML
from web_wework.util.file_operator import YmlOperator


class ContactPage(BasePage):
	"""通讯录页面"""
	# 添加定位元素到locators
	BasePage.locators.update(YmlOperator(ELEMENT_YML['cp']).data)

	def goto_add_member(self):
		"""跳转到添加成员页面"""
		from web_wework.page.add_member_page import AddMemberPage

		self.add_member.click()
		return AddMemberPage(self.driver)

	def goto_add_department(self):
		"""跳转到添加部门页面"""
		from web_wework.page.add_department_page import AddDepartmentPage

		self.btn_add.click()
		self.add_department.click()
		return AddDepartmentPage(self.driver)

	def get_contact_name_list(self):
		"""获取通讯录成员列表"""
		return [ele.text for ele in self.member_name]

	def get_contact_part_name_list(self):
		"""获取部门名称列表"""
		self.driver.refresh()  # 刷新
		sleep(1)
		return [ele.text for ele in self.part_name]
